#include "StdAfx.h"
#include ".\connmgr.h"

namespace Lumin {
namespace Win32 {

CConnMgr::CConnMgr(void)
{

}

CConnMgr::~CConnMgr(void)
{

}

int CConnMgr::GetCount()
{
	CCriticalSection::Owner lock(m_criticalSection);
	return m_mapConnection.size();
}

void CConnMgr::Add(IConnection* pConnection)
{
	CCriticalSection::Owner lock(m_criticalSection);
	m_mapConnection[pConnection] = 0;
}

void CConnMgr::Remove(IConnection* pConnection)
{
	CCriticalSection::Owner lock(m_criticalSection);
	map<IConnection*,DWORD>::iterator iter = m_mapConnection.find(pConnection);
		if(iter != m_mapConnection.end()){
		m_mapConnection.erase(iter);
	}
}

void CConnMgr::Shutdown()
{
	map<IConnection*,DWORD>::iterator iter = m_mapConnection.begin();
	for(; iter != m_mapConnection.end(); iter++){
		iter->first->Shutdown();
	}
}

}
}